/**
 * 
 */
package org.sevaapp.controller;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

/**
 * @author Srini
 *
 */
public abstract class BaseSevaController {

	private static final Log log = LogFactory.getLog(BaseSevaController.class);
	
	@InitBinder
	protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) {
		log.debug("initBinder() method called.");
		String dtFormat = "MM/dd/yyyy";
		SimpleDateFormat dateFormat = new SimpleDateFormat(dtFormat, request.getLocale());
		dateFormat.setLenient(false);
		binder.registerCustomEditor(Date.class, null, new CustomDateEditor(dateFormat, true));
	}

}
